<?php
namespace org;
use think\Request;

/**
 * 本地化调试输出到文件
 */
class LogFile extends \think\log\driver\File {
  
  public function __construct($config = []) {
    parent::__construct($config);
    $req = Request::instance();
    $host = $req->host(true);
    $port = $req->port();
    if (!empty($host)) {
      $path = trim($this->config['path'], '\/');
      $path = $path.DS.$host.(in_array($port, [80, 443]) ? '' : ".{$port}").DS;
      $this->config['path'] = $path;
    }
  }
  
}
